package com.sc.nft.consume;

import com.sc.nft.dao.UserInfoDao;
import com.sc.nft.entity.UserInfo;
import com.sc.nft.enums.MessageTopic;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@RocketMQMessageListener(topic = MessageTopic.USER_REGISTER + "${spring.profiles.active}", consumerGroup = MessageTopic.USER_REGISTER + "${spring.profiles.active}")
@Component
@Slf4j
@RequiredArgsConstructor
public class RegisterConsumer implements RocketMQListener<UserInfo> {

    @Resource
    private UserInfoDao userInfoDao;

    @Override
    public void onMessage(UserInfo userInfo) {
        userInfoDao.addInviteNumByUser(userInfo);
//        userInfoDao.addThirdInviteNumByUser(userInfo);
    }

}
